home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2002 November / SGI IRIX Base Documentation 2002 November.iso / usr / share / catman / p_man / cat3 / librw / RWTPtrHashMapIterator.z / RWTPtrHashMapIterator
Encoding:
Text File  |  2002-10-03  |  8.2 KB  |  199 lines

  1.  
  2.  
  3.  
  4. RRRRWWWWTTTTPPPPttttrrrrHHHHaaaasssshhhhMMMMaaaappppIIIItttteeeerrrraaaattttoooorrrr((((3333CCCC++++++++))))                        RRRRWWWWTTTTPPPPttttrrrrHHHHaaaasssshhhhMMMMaaaappppIIIItttteeeerrrraaaattttoooorrrr((((3333CCCC++++++++))))
  5.  
  6.  
  7.  
  8. NNNNaaaammmmeeee
  9.      RWTPtrHashMapIterator<K,T,H,EQ> - Rogue Wave library class
  10.  
  11. SSSSyyyynnnnooooppppssssiiiissss
  12.               #include<rw/tphdict.h>
  13.  
  14.  
  15.  
  16.               RWTPtrHashMap<K,T,H,EQ> m;
  17.           RWTPtrHashMap<K,T,H,EQ> itr(m);
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24. PPPPlllleeeeaaaasssseeee NNNNooootttteeee!!!!
  25.      IIIIffff yyyyoooouuuu hhhhaaaavvvveeee tttthhhheeee SSSSttttaaaannnnddddaaaarrrrdddd CCCC++++++++ LLLLiiiibbbbrrrraaaarrrryyyy,,,, uuuusssseeee tttthhhheeee iiiinnnntttteeeerrrrffffaaaacccceeee ddddeeeessssccccrrrriiiibbbbeeeedddd hhhheeeerrrreeee....
  26.      OOOOtttthhhheeeerrrrwwwwiiiisssseeee,,,, uuuusssseeee tttthhhheeee iiiinnnntttteeeerrrrffffaaaacccceeee ffffoooorrrr RRRRWWWWTTTTPPPPttttrrrrHHHHaaaasssshhhhDDDDiiiiccccttttiiiioooonnnnaaaarrrryyyyIIIItttteeeerrrraaaattttoooorrrr described
  27.      in Appendix A.
  28.  
  29.  
  30. DDDDeeeessssccccrrrriiiippppttttiiiioooonnnn
  31.      RRRRWWWWTTTTPPPPttttrrrrHHHHaaaasssshhhhMMMMaaaappppIIIItttteeeerrrraaaattttoooorrrr is supplied with TTTToooooooollllssss....hhhh++++++++ 7.x to provide an
  32.      iterator interface to the Standard Library based collections that has
  33.      backward compatibility with the container iterators provided in TTTToooooooollllssss....hhhh++++++++
  34.      6.x. Iteration over an RRRRWWWWTTTTPPPPttttrrrrHHHHaaaasssshhhhMMMMaaaapppp is pseudorandom and dependent on the
  35.      capacity of the underlying hash table and the hash function being used.
  36.      The current item referenced by this iterator is undefined after
  37.      construction or after a call to rrrreeeesssseeeetttt(((()))).  The iterator becomes valid
  38.      after being advanced with either a preincrement or ooooppppeeeerrrraaaattttoooorrrr(((()))).  For both
  39.      ooooppppeeeerrrraaaattttoooorrrr++++++++ and ooooppppeeeerrrraaaattttoooorrrr(((()))), iterating past the last element will return a
  40.      value equivalent to boolean ffffaaaallllsssseeee.  Once this state is reached, continued
  41.      increments will return a value equivalent to ffffaaaallllsssseeee until rrrreeeesssseeeetttt(((()))) is
  42.      called.
  43.  
  44. PPPPeeeerrrrssssiiiisssstttteeeennnncccceeee
  45.      None
  46.  
  47. EEEExxxxaaaammmmpppplllleeeessss
  48.               #include<rw/tphdict.h>
  49.  
  50.  
  51.  
  52.               #include<iostream.h>
  53.           #include<rw/cstring.h>
  54.           struct silly_h{
  55.              unsigned long operator()(RWCString x) const
  56.                { return x.length() * (long)x(0); }
  57.           };
  58.           int main(){
  59.              RWTPtrHashMap
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. RRRRWWWWTTTTPPPPttttrrrrHHHHaaaasssshhhhMMMMaaaappppIIIItttteeeerrrraaaattttoooorrrr((((3333CCCC++++++++))))                        RRRRWWWWTTTTPPPPttttrrrrHHHHaaaasssshhhhMMMMaaaappppIIIItttteeeerrrraaaattttoooorrrr((((3333CCCC++++++++))))
  71.  
  72.  
  73.  
  74.                <RWCString,int,silly_h,equal_to<RWCString> > age;
  75.              RWTPtrHashMapIterator
  76.                <RWCString,int,silly_h,equal_to<RWCString> > itr(age);
  77.              age.insert(new RWCString("John"),new int(30));
  78.              age.insert(new RWCString("Steve"),new int(17));
  79.              age.insert(new RWCString("Mark"),new int(24));
  80.           //Duplicate insertion is rejected
  81.              age.insert(new RWCString("Steve"),new int(24));
  82.              for(;++itr;)
  83.                cout << *itr.key() << "'s age is " << *itr.value() << endl;
  84.              return 0;
  85.           }
  86.           Program Output (not necessarily in this order)
  87.           John's age is 30
  88.           Mark's age is 24
  89.  
  90. PPPPuuuubbbblllliiiicccc CCCCoooonnnnssssttttrrrruuuuccccttttoooorrrrssss
  91.      Steve's age is 17
  92.  
  93.  
  94.  
  95.               RRRRWWWWTTTTPPPPttttrrrrHHHHaaaasssshhhhMMMMaaaappppIIIItttteeeerrrraaaattttoooorrrr<<<<KKKK,,,,TTTT,,,,HHHH,,,,EEEEQQQQ>>>>(RWTPtrHashMap<K,T,H,EQ>&h);
  96.  
  97.  
  98.      Creates an iterator for the hashed map hhhh.  The iterator begins in an
  99.      undefined state and must be advanced before the first element will be
  100.      accessible.
  101.  
  102. PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr OOOOppppeeeerrrraaaattttoooorrrrssss
  103.               K*
  104.           ooooppppeeeerrrraaaattttoooorrrr(((())))();
  105.  
  106.  
  107.      Advances self to the next element, dereferences the resulting iterator
  108.      and returns its key.  If the iterator has advanced past the last item in
  109.      the container,  the element returned will be a nnnniiiillll pointer equivalent to
  110.      boolean ffffaaaallllsssseeee.
  111.  
  112.               RWBoolean
  113.           ooooppppeeeerrrraaaattttoooorrrr++++++++();
  114.  
  115.  
  116.      Advances self to the next element.  If the iterator has been reset or
  117.      just created self will now reference the first element.  If, before
  118.      iteration, self referenced the last association in the multi-map, self
  119.      will now reference an undefined value and a value equivalent to ffffaaaallllsssseeee
  120.      will be returned.  Otherwise, a value equivalent to ttttrrrruuuueeee is returned.
  121.      Note: no post-increment operator is provided.
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. RRRRWWWWTTTTPPPPttttrrrrHHHHaaaasssshhhhMMMMaaaappppIIIItttteeeerrrraaaattttoooorrrr((((3333CCCC++++++++))))                        RRRRWWWWTTTTPPPPttttrrrrHHHHaaaasssshhhhMMMMaaaappppIIIItttteeeerrrraaaattttoooorrrr((((3333CCCC++++++++))))
  137.  
  138.  
  139.  
  140. Public Member Functions
  141.               RWTPtrHashMap<K,T,H,EQ>*
  142.           ccccoooonnnnttttaaaaiiiinnnneeeerrrr(((()))) const;
  143.  
  144.  
  145.      Returns a pointer to the collection being iterated over.
  146.  
  147.               K*
  148.           kkkkeeeeyyyy() const;
  149.  
  150.  
  151.      Returns the key portion of the association currently referenced by self.
  152.      Undefined if self is not referencing a value within the map.
  153.  
  154.               void
  155.           rrrreeeesssseeeetttt();
  156.           void
  157.           rrrreeeesssseeeetttt(RWTPtrHashMap<K,T,H,EQ>& h);
  158.  
  159.  
  160.      Resets the iterator so that after being advanced it will reference the
  161.      first element of the collection.  Using rrrreeeesssseeeetttt(((()))) with no argument will
  162.      reset the iterator on the current container.  Supplying a hashed map with
  163.      rrrreeeesssseeeetttt(((()))) will reset the iterator on that container.
  164.  
  165.               T*
  166.           vvvvaaaalllluuuueeee();
  167.  
  168.  
  169.      Returns the value portion of the association pointed to by self.  The
  170.      behavior is undefined if the map is empty.
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.